package show.me.the.money.validator;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;

public class DispatchVType {
	
	public static final String MSG = "";
	
	protected String execute(HashMap<String, Object> rec, String[] args) {
		String msg = "";
		String method = args[0];
		for (int i = 1; i < args.length; i++) {
			String fid = args[i];
			if (fid.contains(".")) {
				fid = fid.substring(fid.indexOf(".") + 1);
			}
			args[i] = (rec.get(fid) == null) ? "" : String
					.valueOf(rec.get(fid));
		}
		args = Arrays.copyOfRange(args, 1, args.length);
		try {
			Method m = this.getClass().getMethod(method,
					new Class[] { args.getClass() });
			msg = (String) m.invoke(this, new Object[] { args });
		} catch (Exception e) {
		}
		return msg;
	}
}
